package spike.s003.sqlflow.entity;

import org.springframework.jdbc.core.BeanPropertyRowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * Created by ylyang on 04/04/2017.
 */
public class StudentQQEntity {
    private String studentID;
    private String qqNum;
    private Date createTime;
    private QQEntity qqEntity;

    public String getStudentID() {
        return studentID;
    }

    public void setStudentID(String studentID) {
        this.studentID = studentID;
    }

    public String getQqNum() {
        return qqNum;
    }

    public void setQqNum(String qqNum) {
        this.qqNum = qqNum;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public QQEntity getQqEntity() {
        return qqEntity;
    }

    public void setQqEntity(QQEntity qqEntity) {
        this.qqEntity = qqEntity;
    }

    public static class BeanRowMapper {
        private static final BeanPropertyRowMapper<StudentQQEntity> MAPPER = BeanPropertyRowMapper.newInstance(StudentQQEntity.class);

        public static StudentQQEntity mapRow(ResultSet rs) throws SQLException {
            String s = rs.getString("student_ID");

            StudentQQEntity studentQQEntity = MAPPER.mapRow(rs, rs.getRow());
            studentQQEntity.setStudentID(s);
            studentQQEntity.setQqNum(rs.getString("qq_num"));
            studentQQEntity.setCreateTime(rs.getDate("create_time"));
            return studentQQEntity;
        }
    }

    @Override
    public String toString() {
        return "StudentQQEntity{" +
                "studentID='" + studentID + '\'' +
                ", qqNum='" + qqNum + '\'' +
                ", createTime=" + createTime +
                ", qqEntity=" + qqEntity +
                '}';
    }
}
